<?php
require_once './common.php';
//require_once ABSPATH . '/class/StrainDataFetcher.class.php';
//require_once ABSPATH . '/class/InteractionDataFetcher.class.php';
//require_once ABSPATH . '/class/CorrelationDataFetcher.class.php';
//require_once ABSPATH . '/class/SearchAction.class.php';
//require_once ABSPATH . '/class/BlockData.class.php';
require_once ABSPATH . '/class/AutoCompleteData.class.php';
//$keywords = 'Golgi vesicle transport, macromolecule localization, GET3';
//$filename = ABSPATH . '/data/FG30_allEnrich_condBlocks.csv';
//$filepath = ABSPATH . '/data/blockImages';
//$blockdata_service = new BlockData();
//$result = $blockdata_service->get_block_id($keywords);
//var_dump($result);
$saved_file = ABSPATH . '/inc/js/localdata.js';
$mode = 'w';
$autocomplete = new AutoCompleteData();
$autocomplete->get_autocomplete_data($saved_file, $mode);
echo "OK<br/>";
//$blockdata_service->get_block_interaction($filepath);
//$blockdata_service->get_data($filename);

//$strain_fetcher = new StrainDataFetcher();
//
//$strain_fetcher->add_new_strain();
//$interaction_service = new InteractionDataFetcher();

//
//$id = $test_service->get_strain_id(12, 'frae');
//if ($id == NULL){
//    echo "ID = 0<br/>";
//} else {
//    echo "ID = " . $id . '<br/>';
//}
//$filename = 'TS30_120210_scored_120212.txt';
//
//$names = explode('_', $filename);
//$temperature = substr($names[0], 0, 2);
//$type = substr($names[0], 2, 2);
//
//echo 'temperature = ' . $temperature . ' and type = ' . $type . '<br/>';

//$interaction_service->add_new_interation();

//$correlation_service = new CorrelationDataFetcher();
//$correlation_service->add_correlation();


/******************************************************************
 *                 测试strain中是否有重复数据                         *
 ******************************************************************/
/*
$result_array = array();
$flag = FALSE;
$sql = 'SELECT gene_id, name FROM strain';
global $global_sga_conn;
$result = get_array_from_resultset($global_sga_conn->Execute($sql));
foreach ($result as $item){
    if (!in_array($item['gene_id'] . '_' . $item['name'], $result_array)){
        array_push($result_array, $item['gene_id'] . '_' . $item['name']);
    } else {
        $flag = TRUE;
        echo '有重复，重复的内容是' . $item['gene_id'] . '_' . $item['name'] . '<br/>';
    }
}

if (!$flag){
    echo '没有重复数据<br/>';
}
 * 
 */
/******************************************************************
 *                          测试结束                                *
 ******************************************************************/

/******************************************************************
 *                       测试SearchAction                          *
 ******************************************************************/
/*
$search_action = new SearchActionClass();
$gene = 'YFR005C';
$type = 'p';
$score = 0.08;
$p_value = 0.05;

$array_result = $search_action->get_interaction_result_with($gene, $type, $score, $p_value);

foreach($array_result as $items){
        var_dump($items);
}
 */
/******************************************************************
 *                          测试结束                                *
 ******************************************************************/

/******************************************************************
 *                       测试array自定义排序                         *
 ******************************************************************/
/*
function my_sort($a, $b) {
    if ($a['score'] == $b['score'])
        return 0;
    if ($a['score'] < 0 && $b['score'] < 0) {
        return ($a['score'] < $b['score']) ? -1 : 1;
    } else {
        return ($a['score'] > $b['score']) ? -1 : 1;
    }
}

$test_array = array(
    1 => array(
        'g1id' => '6549',
        'g1fn' => 'YIL008W',
        'g2id' => '5401',
        'g2fn' => 'YFR005C',
        's1n' => 'sn4146',
        's2n' => 'tsa700',
        'score' => '-0.180329',
        'tcondition' => '4',
    )
    , 
    5 => array(
        'g1id' => '5688',
        'g1fn' => 'YGL043W',
        'g2id' => '5401',
        'g2fn' => 'YFR005C',
        's1n' => 'sn1428',
        's2n' => 'tsa700',
        'score' => '-0.109595',
        'tcondition' => '4',
    )
    , 
    3 => array('g1id' => '6119',
        'g1fn' => 'YHR012W',
        'g2id' => '5401',
        'g2fn' => 'YFR005C',
        's1n' => 'sn450',
        's2n' => 'tsa700',
        'score' => '-0.172423',
        'tcondition' => '4',
    )
);
//uasort($test_array, "my_sort");

var_dump ($test_array);
echo '<br/>';
$aaaa = $test_array[3];
unset($test_array);
var_dump($aaaa);
 * 
 */
/******************************************************************
 *                          测试结束                                *
 ******************************************************************/
